package com.sany.taskmanager.manager;


import com.sany.taskmanager.bean.ColorBean;
import com.sany.taskmanager.bean.FactoryBean;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class DataManager {
    private List<ColorBean> mColorList;
    private Map<Integer, ColorBean> mColorMap;
    private Map<String, Integer> mColorSIMap;
    private final List<FactoryBean> mFactoryList;
    private String mFactoryCode;
    private static volatile DataManager mInstance;


    private DataManager() {
        mFactoryList = new ArrayList<>();
    }

    public static DataManager getInstance() {
        if (mInstance == null) {
            synchronized (DataManager.class) {
                if (mInstance == null) {
                    mInstance = new DataManager();
                }
            }
        }
        return mInstance;
    }

    public void init() {
        mFactoryList.add(new FactoryBean("3G01", "三一中起线边仓"));
        mFactoryList.add(new FactoryBean("3110", "起重机线边仓"));
    }

    public void setColorList(List<ColorBean> colorList) {
        mColorList = colorList;
        mColorMap = new HashMap<>();
        mColorSIMap = new HashMap<>();
        for (ColorBean item : mColorList) {
            mColorMap.put(item.getColorType(), item);
            mColorSIMap.put(item.getColorName(), item.getColorType());
        }
    }

    public List<ColorBean> getColorList() {
        return mColorList;
    }

    public Map<Integer, ColorBean> getColorMap() {
        return mColorMap;
    }

    public Map<String, Integer> getColorSIMap() {
        return mColorSIMap;
    }

    public List<FactoryBean> getFactoryList() {
        return mFactoryList;
    }

    public void setFactoryCode(String factoryCode) {
        mFactoryCode = factoryCode;
    }

    public String getFactoryCode() {
        return mFactoryCode;
    }
}
